<p>支付地址：<span></span></p>
<button>去支付</button>


<script>
// 支付地址
let tmp = GetDateNow()
let url = `pagepay/pagepay.php?trade_no=${tmp}&amount=0.01`;

// 显示支付地址
let span = document.querySelector("span")
span.innerHTML = url

// 去支付
let btnObj = document.querySelector("button")
    btnObj.onclick = function() {
    location.href = url
}

function GetDateNow() {
    var vNow = new Date();
    var sNow = "";
    sNow += String(vNow.getFullYear());
    sNow += String(vNow.getMonth() + 1);
    sNow += String(vNow.getDate());
    sNow += String(vNow.getHours());
    sNow += String(vNow.getMinutes());
    sNow += String(vNow.getSeconds());
    sNow += String(vNow.getMilliseconds());
    return sNow + random(111, 999);
}

function random(lower, upper) {
	return Math.floor(Math.random() * (upper - lower)) + lower;
}
</script>